﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:p="clr-namespace:Lithnet.Acma.Presentation"
                    xmlns:AvalonEdit="clr-namespace:ICSharpCode.AvalonEdit;assembly=ICSharpCode.AvalonEdit"
                    xmlns:a="clr-namespace:Lithnet.Acma;assembly=Lithnet.Acma"
                    xmlns:c="clr-namespace:Lithnet.MetadirectoryServices;assembly=Lithnet.MetadirectoryServices"
                    xmlns:fim="clr-namespace:Microsoft.MetadirectoryServices;assembly=Microsoft.MetadirectoryServicesEx"
                    xmlns:core="clr-namespace:Lithnet.Common.Presentation;assembly=Lithnet.Common.Presentation">

    <DataTemplate  DataType="{x:Type p:AdvancedComparisonRuleViewModel}">
        <StackPanel>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <Label Content="Group operator"
                       Grid.Row="0"
                       Grid.Column="0"
                       Margin="2" />

                <ComboBox ItemsSource="{Binding Source={core:EnumExtension {x:Type a:GroupOperator}}}"
                          SelectedValue="{Binding Path=GroupOperator, ValidatesOnDataErrors=True, ValidatesOnExceptions=true}"
                          SelectedValuePath="Value"
                          Grid.Row="0"
                          Grid.Column="1"
                          Margin="2" />

                <Label Content="First value"
                       Grid.Row="1"
                       Grid.Column="0"
                       Margin="2" />

                <Grid Grid.Row="1"
                      Grid.Column="1">
                    <Grid.RowDefinitions>
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Border Grid.Row="0"
                            Grid.Column="0"
                            CornerRadius="0"
                            Padding="2"
                            Margin="2"
                            BorderThickness="1"
                            BorderBrush="Black">
                        <p:DeclarationEditBox Text="{Binding Path=SourceValue.Declaration, Mode=TwoWay, ValidatesOnDataErrors=True, ValidatesOnExceptions=true}"
                                              DeclarationMode="ComplexAttributeDeclaration"
                                              ObjectClass="{Binding Path=SourceValue.ObjectClass, Mode=OneWay}"
                                              SyntaxErrors="{Binding Path=SourceValue.SyntaxErrors, Mode=OneWayToSource}"
                                              Margin="1" />
                    </Border>
                    <Label Content="Transforms"
                           Grid.Row="0"
                           Grid.Column="1"
                           Margin="2" />
                    <Border Grid.Row="0"
                            Grid.Column="2"
                            CornerRadius="0"
                            Padding="2"
                            Margin="2"
                            BorderThickness="1"
                            BorderBrush="Black">
                        <p:TransformEditBox Text="{Binding Path=SourceValue.TransformsString, Mode=TwoWay, ValidatesOnDataErrors=True, ValidatesOnExceptions=true}"
                                            Margin="1" />
                    </Border>
                </Grid>

                <Label Content="Operator"
                       Grid.Row="2"
                       Grid.Column="0"
                       Margin="2" />
                <ComboBox ItemsSource="{Binding Path=AllowedValueOperators}"
                          SelectedValue="{Binding Path=ValueOperator, ValidatesOnDataErrors=True, ValidatesOnExceptions=true}"
                          SelectedValuePath="Value"
                          Grid.Row="2"
                          Grid.Column="1"
                          Margin="2" />

                <Label Content="Second value"
                       Grid.Row="3"
                       Grid.Column="0"
                       Margin="2" />

                <Grid Grid.Row="3"
                      Grid.Column="1">
                    <Grid.RowDefinitions>
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Border Grid.Row="0"
                            Grid.Column="0"
                            CornerRadius="0"
                            Padding="2"
                            Margin="2"
                            BorderThickness="1"
                            BorderBrush="Black">
                        <p:DeclarationEditBox Text="{Binding Path=TargetValue.Declaration, Mode=TwoWay, ValidatesOnDataErrors=True, ValidatesOnExceptions=true}"
                                              DeclarationMode="ComplexAttributeDeclaration"
                                              ObjectClass="{Binding Path=TargetValue.ObjectClass, Mode=OneWay}"
                                              SyntaxErrors="{Binding Path=TargetValue.SyntaxErrors, Mode=OneWayToSource}"
                                              Margin="1"
                                              IsEnabled="{Binding Path=IsSecondValueAllowed}" />
                    </Border>
                    <Label Content="Transforms"
                           Grid.Row="0"
                           Grid.Column="1"
                           Margin="2" />
                    <Border Grid.Row="0"
                            Grid.Column="2"
                            CornerRadius="0"
                            Padding="2"
                            Margin="2"
                            BorderThickness="1"
                            BorderBrush="Black">
                        <p:TransformEditBox Text="{Binding Path=TargetValue.TransformsString, Mode=TwoWay, ValidatesOnDataErrors=True, ValidatesOnExceptions=true}"
                                            Margin="1"
                                            IsEnabled="{Binding Path=IsSecondValueAllowed}" />
                    </Border>
                </Grid>

                <Label Content="Compare as"
                       Grid.Row="4"
                       Grid.Column="0"
                       Margin="2" />

                <ComboBox ItemsSource="{Binding Source={core:EnumExtension {x:Type c:ExtendedAttributeType}}}"
                          SelectedValue="{Binding Path=CompareAs, ValidatesOnDataErrors=True, ValidatesOnExceptions=true}"
                          SelectedValuePath="Value"
                          Grid.Row="4"
                          Grid.Column="1"
                          Margin="2" />
            </Grid>
        </StackPanel>
    </DataTemplate>

</ResourceDictionary>